home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_A / HARDIRQ.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-17  |  1.7 KB  |  80 lines

  1. /* hardirq.h: 64-bit Sparc hard IRQ support.
  2.  *
  3.  * Copyright (C) 1997, 1998 David S. Miller (davem@caip.rutgers.edu)
  4.  */
  5.  
  6. #ifndef __SPARC64_HARDIRQ_H
  7. #define __SPARC64_HARDIRQ_H
  8.  
  9. #include <linux/tasks.h>
  10.  
  11. #ifndef __SMP__
  12. extern unsigned int local_irq_count;
  13. #else
  14. #define local_irq_count        (cpu_data[smp_processor_id()].irq_count)
  15. #endif
  16.  
  17. /*
  18.  * Are we in an interrupt context? Either doing bottom half
  19.  * or hardware interrupt processing?
  20.  */
  21. #define in_interrupt() ((local_irq_count + local_bh_count) != 0)
  22.  
  23. #ifndef __SMP__
  24.  
  25. #define hardirq_trylock(cpu)    (local_irq_count == 0)
  26. #define hardirq_endlock(cpu)    do { } while(0)
  27.  
  28. #define hardirq_enter(cpu)    (local_irq_count++)
  29. #define hardirq_exit(cpu)    (local_irq_count--)
  30.  
  31. #define synchronize_irq()    barrier()
  32.  
  33. #else /* (__SMP__) */
  34.  
  35. #include <asm/atomic.h>
  36. #include <asm/spinlock.h>
  37. #include <asm/system.h>
  38. #include <asm/smp.h>
  39.  
  40. extern unsigned char global_irq_holder;
  41. extern spinlock_t global_irq_lock;
  42. extern atomic_t global_irq_count;
  43.  
  44. static inline void release_irqlock(int cpu)
  45. {
  46.     /* if we didn't own the irq lock, just ignore... */
  47.     if(global_irq_holder == (unsigned char) cpu) {
  48.         global_irq_holder = NO_PROC_ID;
  49.         spin_unlock(&global_irq_lock);
  50.     }
  51. }
  52.  
  53. static inline void hardirq_enter(int cpu)
  54. {
  55.     ++(cpu_data[cpu].irq_count);
  56.     atomic_inc(&global_irq_count);
  57.     membar("#StoreLoad | #StoreStore");
  58. }
  59.  
  60. static inline void hardirq_exit(int cpu)
  61. {
  62.     membar("#StoreStore | #LoadStore");
  63.     atomic_dec(&global_irq_count);
  64.     --(cpu_data[cpu].irq_count);
  65. }
  66.  
  67. static inline int hardirq_trylock(int cpu)
  68. {
  69.     return (! atomic_read(&global_irq_count) &&
  70.         ! spin_is_locked (&global_irq_lock));
  71. }
  72.  
  73. #define hardirq_endlock(cpu)    do { } while (0)
  74.  
  75. extern void synchronize_irq(void);
  76.  
  77. #endif /* __SMP__ */
  78.  
  79. #endif /* !(__SPARC64_HARDIRQ_H) */
  80.